package common

import (
	"encoding/json"

	"github.com/saintfish/chardet"
)

func getContentCharset(content []byte) (charset string) {
	detector := chardet.NewHtmlDetector()
	result, err := detector.DetectBest(content)
	if err != nil {
		logger.Error("%s", err)
		return
	}
	logger.Debug("detect charset:%v", result)
	charset = result.Charset
	return

}
func JsonDump(v interface{}) []byte {
	b, err := json.MarshalIndent(v, "", " ")
	if err != nil {
		return []byte{}
	}
	return b
}
